import asyncio
import websockets

import websocket


def on_open(ws):
    print("连接已建立1")


def on_message(ws, message):
    print("收到消息：", message)


def on_close(ws,error1,error2):
    print(f"连接已关闭,{error1},{error2}")


def on_error(ws, error1):
    print("发生错误：", error1)


# 创建WebSocket连接
ws = websocket.WebSocketApp("ws://123.249.111.172:18088/uav/landServer/F6EA145EA18DF786C2FC5C7239C4E4CBAA906823B6871D1FFDF16CC185FF7CC991F9299D5E4D8EE376A95A99EA6AA48F1A3FF2864DE5A8CCAF5A9D9E016E5CFF",
                            on_open=on_open,
                            on_message=on_message,
                            on_close=on_close,
                            on_error=on_error)

# 启动WebSocket客户端
ws.run_forever()
